#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QtDBus/QDBusConnection>
#include <QtDBus/QDBusInterface>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}


void MainWindow::on_pushButton_clicked()
{
    ui->label->clear();
    if(ui->lineEdit->text().isEmpty()) {
        ui->label->setText("用户为空");
        return;
    }
    QString usr = ui->lineEdit->text();

    QDBusInterface *iface = new QDBusInterface("com.demo.qt.systemdbus", \
                           "/", \
                           "com.demo.interface", \
                           QDBusConnection::systemBus());
    iface->call("creatUser",usr,qApp->applicationPid());
}
